import request from '@/utils/request'

// 查询同步任务列表
export function listSync(query) {
  return request({
    url: '/system/datasync/list',
    method: 'get',
    params: query
  })
}

// 查询同步任务详细
export function getSync(syncId) {
  return request({
    url: '/system/datasync/' + syncId,
    method: 'get'
  })
}

// 新增同步任务
export function addSync(data) {
  return request({
    url: '/system/datasync',
    method: 'post',
    data: data
  })
}

// 修改同步任务
export function updateSync(data) {
  return request({
    url: '/system/datasync',
    method: 'put',
    data: data
  })
}

// 删除同步任务
export function delSync(syncId) {
  return request({
    url: '/system/datasync/' + syncId,
    method: 'delete'
  })
}

// 执行同步任务
export function runSync(syncId) {
  return request({
    url: '/system/datasync/run/' + syncId,
    method: 'get'
  })
}

// 查询同步日志列表
export function listSyncLog(query) {
  return request({
    url: '/system/datasync/log/list',
    method: 'get',
    params: query
  })
}

// 查询同步日志详细
export function getSyncLog(logId) {
  return request({
    url: '/system/datasync/log/' + logId,
    method: 'get'
  })
}

// 删除同步日志
export function delSyncLog(logId) {
  return request({
    url: '/system/datasync/log/' + logId,
    method: 'delete'
  })
}

// 获取服务器列表
export function getServerList() {
  return request({
    url: '/system/datasync/server/list',
    method: 'get'
  })
}

// 查询服务器详细
export function getServer(serverId) {
  return request({
    url: '/system/datasync/server/' + serverId,
    method: 'get'
  })
}

// 新增服务器
export function addServer(data) {
  return request({
    url: '/system/datasync/server',
    method: 'post',
    data: data
  })
}

// 修改服务器
export function updateServer(data) {
  return request({
    url: '/system/datasync/server',
    method: 'put',
    data: data
  })
}

// 删除服务器
export function delServer(serverId) {
  return request({
    url: '/system/datasync/server/' + serverId,
    method: 'delete'
  })
}

// 测试服务器连接
export function testServerConnection(serverId) {
  return request({
    url: '/system/datasync/server/test/' + serverId,
    method: 'get'
  })
}